<%--
  Created by IntelliJ IDEA.
  User: wesley.wei
  Date: 2018-06-01
  Time: 13:30
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>layout 后台大布局 - Layui</title>
    <link rel="stylesheet" href="/componments/layui/css/layui.css">
    <style>
        .grid-demo-bg1 {
            background-color: #63BA79;
        }
        .grid-demo {
            background-color: #63BA78;
        }
    </style>
</head>
<body class="layui-layout-body">

            <div class="layui-elem-quote layui-quote-nm t-body">
                <i class="line"></i>查询条件<em class="flip" id="flip_user"></em>
                <form class="layui-form" action="" id="search_user_form">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">登录账户</label>
                            <div class="layui-input-inline">
                                <input name="username" class="layui-input" type="text" >
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">登录名称</label>
                            <div class="layui-input-inline">
                                <input class="layui-input" id="search_user_userName" placeholder="" type="text" name="realName">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">部门</label>
                            <div class="layui-input-inline">
                                <select class="layui-input" id="search_user_dept" lay-filter="search_user_dept" name="deptId">
                                    <option value="-1">请选择</option>

                                </select>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">班组</label>
                            <div class="layui-input-inline">
                                <select class="layui-input" id="search_user_team" lay-filter="search_user_team"  name="teamId">
                                    <option value="-1">请选择</option>
                                </select>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">组别</label>
                            <div class="layui-input-inline">
                                <select class="layui-input" id="search_user_teamType" lay-filter="search_user_teamType"  name="teamTypeId">
                                    <option value="-1">请选择</option>
                                </select>
                            </div>
                        </div>

                        <div class="layui-inline" style="float: right; margin-right: 44px; margin-top: 10px">
                            <a class="layui-btn" id="search_user_btn" onclick="">搜索</a>
                            <a class="layui-btn"  onclick="">重置</a>
                        </div>
                    </div>
                </form>
            </div>


            <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                <legend>查询结果</legend>
            </fieldset>

            <div class="layui-btn-group">
                <button class="layui-btn" onclick="getSelectedRow()">获取数据</button>
                <button class="layui-btn" onclick="addUser()">增加</button>
                <button class="layui-btn">编辑</button>
                <button class="layui-btn">删除</button>
            </div>

            <table class="layui-table" lay-data="{url:'/datas/user.json', page:true, id:'testTable'}" lay-filter="test">
                <thead>
                <tr>
                    <th lay-data="{checkbox:true, fixed: true}"></th>
                    <th lay-data="{field:'id', sort: true}">ID</th>
                    <th lay-data="{field:'username'}">用户名</th>
                    <th lay-data="{field:'sex', sort: true}">性别</th>
                    <th lay-data="{field:'city'}">城市</th>
                    <th lay-data="{field:'sign'}">签名</th>
                    <th lay-data="{field:'experience',  sort: true}">积分</th>
                    <th lay-data="{field:'score', sort: true}">评分</th>
                    <th lay-data="{field:'classify'}">职业</th>
                    <th lay-data="{field:'wealth', sort: true}">财富</th>
                    <th lay-data="{fixed: 'right', align:'center', toolbar: '#barDemo'}">工具栏</th>
                </tr>
                </thead>
            </table>

</div>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-primary layui-btn-mini" lay-event="detail">查看</a>
    <a class="layui-btn layui-btn-mini" lay-event="edit">编辑</a>
    <a class="layui-btn layui-btn-danger layui-btn-mini" lay-event="del">删除</a>
</script>
<script src="/componments/layui/layui.js"></script>
<script>
    var table = undefined;

    layui.use(['element','table'], function(){
        table = layui.table;

        //监听工具条,test是layui-table的lay-filter值
        table.on('tool(test)', function(obj){
            var data = obj.data;
            if(obj.event === 'detail'){
                layer.msg('ID：'+ data.id + ' 的查看操作');
            } else if(obj.event === 'del'){
                layer.confirm('真的删除行么', function(index){
                    obj.del();
                    layer.close(index);
                });
            } else if(obj.event === 'edit'){
                layer.alert('编辑行：<br>'+ JSON.stringify(data))
            }
        });

        /* var $ = layui.$, active = {
          getCheckData: function(){ //获取选中数据
            var checkStatus = table.checkStatus('testTable')
            ,data = checkStatus.data;
            layer.alert(JSON.stringify(data));
          }
          ,getCheckLength: function(){ //获取选中数目
            var checkStatus = table.checkStatus('testTable')
            ,data = checkStatus.data;
            layer.msg('选中了：'+ data.length + ' 个');
          }
          ,isAll: function(){ //验证是否全选
            var checkStatus = table.checkStatus('testTable');
            layer.msg(checkStatus.isAll ? '全选': '未全选')
          }
        };

        $('.demoTable .layui-btn').on('click', function(){
          var type = $(this).data('type');
          active[type] ? active[type].call(this) : '';
        }); */

    });

    function addUser(){
        layer.open({
            title: '这是添加页面',
            area: ['893px', '600px'],
            content: 'add.html',
            yes:function(index, layero){
                layer.close(index); //如果设定了yes回调，需进行手工关闭
            }
        });
    }

    function getSelectedRow(){
        var checkStatus = table.checkStatus('testTable');
        data = checkStatus.data;
        if(data == ''){
            layer.alert('请选择数据');
            return;
        }
        layer.alert(JSON.stringify(data))
    }
</script>
</body>
</html>
